﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ch04
{
    class Class4
    {
        static void Main(string[] args)
        {
            //让用户输入一个日期，显示是该年的第几天
            Console.Write("请输入日期：");
            string date = Console.ReadLine();
            
            //获取日期字符串中的年月日
            string[] arr = date.Split('-','/');
            int year = int.Parse(arr[0]);
            int month = int.Parse(arr[1]);
            int day = int.Parse(arr[2]);

            Console.WriteLine("{0}年{1}月{2}日",year,month,day);

            //定义变量保存总天数
            int days = 0;

            for (int i = 1; i < month; i++)
            {
                switch (i)
                {
                    case 2:days += (year%4==0&&year%100!=0||year%400==0)?29:28;break;
                    case 4:
                    case 6:
                    case 9:
                    case 11: days += 30; break;
                    default: days += 31; break;
                }
            }

            days += day;

            Console.WriteLine("该日期是这一年的第{0}天!", days);

        }
    }
}
